/*
 * Copyright (c) 2017-2019, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __BOARD_H
#define __BOARD_H

#ifdef __cplusplus
extern "C" {
#endif

#include <ti/drivers/Board.h>
#include "LPSTK.h"

#define Board_LPSTK
#define BOARD_STRING            "TI CC1352R SensorTag"

#define Board_initGeneral()      Board_init()  /* deprecated */
#define Board_shutDownExtFlash() LPSTK_shutDownExtFlash()
#define Board_wakeUpExtFlash()   LPSTK_wakeUpExtFlash()

/* These #defines allow us to reuse TI-RTOS across other device families */
#define Board_ADC0              LPSTK_ADC0
#define Board_ADC1              LPSTK_ADC1

#define Board_ADCBUF0           LPSTK_ADCBUF0
#define Board_ADCBUF0CHANNEL0   LPSTK_ADCBUF0CHANNEL0
#define Board_ADCBUF0CHANNEL1   LPSTK_ADCBUF0CHANNEL1

#define Board_ECDH0             LPSTK_ECDH0
#define Board_ECDSA0            LPSTK_ECDSA0
#define Board_ECJPAKE0          LPSTK_ECJPAKE0
#define Board_AESCCM0           LPSTK_AESCCM0
#define Board_AESGCM0           LPSTK_AESGCM0
#define Board_AESCBC0           LPSTK_AESCBC0
#define Board_AESCTR0           LPSTK_AESCTR0
#define Board_AESECB0           LPSTK_AESECB0
#define Board_AESCTRDRBG0       LPSTK_AESCTRDRBG0
#define Board_SHA20             LPSTK_SHA20
#define Board_TRNG0             LPSTK_TRNG0

#define Board_DIO16_TDO         LPSTK_DIO16_TDO
#define Board_DIO17_TDI         LPSTK_DIO17_TDI
#define Board_DIO22             LPSTK_DIO22

#define Board_DIO24_ANALOG      LPSTK_DIO24_ANALOG
#define Board_DIO26_ANALOG      LPSTK_DIO26_ANALOG
#define Board_DIO28_ANALOG      LPSTK_DIO28_ANALOG
#define Board_DIO29_ANALOG      LPSTK_DIO29_ANALOG

/*
 *  Board_RF_SUB1GHZ is the name generated by SysConfig. Define it
 *  here so that RF callback function can reference it.
 */
#define Board_RF_SUB1GHZ        LPSTK_DIO30_RF_SUB1GHZ

#define Board_GPIO_BUTTON0      LPSTK_GPIO_S1
#define Board_GPIO_BUTTON1      LPSTK_GPIO_S2
#define Board_GPIO_BTN1         LPSTK_GPIO_S1
#define Board_GPIO_BTN2         LPSTK_GPIO_S2
#define Board_GPIO_LED0         LPSTK_GPIO_LED_RED
#define Board_GPIO_LED1         LPSTK_GPIO_LED_GREEN
#define Board_GPIO_LED2         LPSTK_GPIO_LED_RED
#define Board_GPIO_RLED         LPSTK_GPIO_LED_RED
#define Board_GPIO_GLED         LPSTK_GPIO_LED_GREEN
#define Board_GPIO_LED_ON       LPSTK_GPIO_LED_ON
#define Board_GPIO_LED_OFF      LPSTK_GPIO_LED_OFF

#define Board_GPTIMER0A         LPSTK_GPTIMER0A
#define Board_GPTIMER0B         LPSTK_GPTIMER0B
#define Board_GPTIMER1A         LPSTK_GPTIMER1A
#define Board_GPTIMER1B         LPSTK_GPTIMER1B
#define Board_GPTIMER2A         LPSTK_GPTIMER2A
#define Board_GPTIMER2B         LPSTK_GPTIMER2B
#define Board_GPTIMER3A         LPSTK_GPTIMER3A
#define Board_GPTIMER3B         LPSTK_GPTIMER3B

#define Board_NVSINTERNAL       LPSTK_NVSCC26XX0
#define Board_NVSEXTERNAL       LPSTK_NVSSPI25X0

#define Board_I2C0              LPSTK_I2C0
#define Board_I2C1              LPSTK_I2C1
#define Board_I2C_TMP           Board_I2C0

#define Board_PIN_BUTTON0       LPSTK_PIN_BTN1
#define Board_PIN_BUTTON1       LPSTK_PIN_BTN2
#define Board_PIN_BTN1          LPSTK_PIN_BTN1
#define Board_PIN_BTN2          LPSTK_PIN_BTN2
#define Board_PIN_LED0          LPSTK_PIN_RLED
#define Board_PIN_LED1          LPSTK_PIN_GLED
#define Board_PIN_LED2          LPSTK_PIN_RLED
#define Board_PIN_RLED          LPSTK_PIN_RLED
#define Board_PIN_GLED          LPSTK_PIN_GLED

#define Board_KEY_LEFT          LPSTK_KEY_LEFT
#define Board_KEY_RIGHT         LPSTK_KEY_RIGHT
#define Board_RELAY             LPSTK_RELAY

#define Board_BUZZER            LPSTK_BUZZER
#define Board_BUZZER_ON         LPSTK_LED_ON
#define Board_BUZZER_OFF        LPSTK_LED_OFF

#define Board_MPU_INT           LPSTK_MPU_INT
#define Board_MPU_POWER         LPSTK_MPU_POWER
#define Board_MPU_POWER_OFF     LPSTK_MPU_POWER_OFF
#define Board_MPU_POWER_ON      LPSTK_MPU_POWER_ON

#define Board_TMP_RDY           LPSTK_TMP_RDY

#define Board_I2S0              LPSTK_I2S0
#define Board_I2S_ADO           LPSTK_I2S_ADO
#define Board_I2S_ADI           LPSTK_I2S_ADI
#define Board_I2S_BCLK          LPSTK_I2S_BCLK
#define Board_I2S_MCLK          LPSTK_I2S_MCLK
#define Board_I2S_WCLK          LPSTK_I2S_WCLK

#define Board_PWM0              LPSTK_PWM0
#define Board_PWM1              LPSTK_PWM1
#define Board_PWM2              LPSTK_PWM2
#define Board_PWM3              LPSTK_PWM3
#define Board_PWM4              LPSTK_PWM4
#define Board_PWM5              LPSTK_PWM5
#define Board_PWM6              LPSTK_PWM6
#define Board_PWM7              LPSTK_PWM7

#define Board_SPI0              LPSTK_SPI0
#define Board_SPI0_MISO         LPSTK_SPI0_MISO
#define Board_SPI0_MOSI         LPSTK_SPI0_MOSI
#define Board_SPI0_CLK          LPSTK_SPI0_CLK
#define Board_SPI0_CSN          LPSTK_SPI0_CSN
#define Board_SPI1              LPSTK_SPI1
#define Board_SPI1_MISO         LPSTK_SPI1_MISO
#define Board_SPI1_MOSI         LPSTK_SPI1_MOSI
#define Board_SPI1_CLK          LPSTK_SPI1_CLK
#define Board_SPI1_CSN          LPSTK_SPI1_CSN
#define Board_SPI_FLASH_CS      LPSTK_SPI_FLASH_CS
#define Board_FLASH_CS_ON       (0)
#define Board_FLASH_CS_OFF      (1)

#define Board_UART0             LPSTK_UART0

#define Board_WATCHDOG0         LPSTK_WATCHDOG0

/* Board specific I2C addresses */
#define Board_BMP280_ADDR       (0x77)
#define Board_HDC1000_ADDR      (0x41)
#define Board_MPU9250_ADDR      (0x68)
#define Board_MPU9250_MAG_ADDR  (0x0C)
#define Board_OPT3001_ADDR      (0x44)
#define Board_TMP_ADDR          (0x45)

#ifdef __cplusplus
}
#endif

#endif /* __BOARD_H */
